import { createSlice } from '@reduxjs/toolkit'
import type { Product } from '../views/production/types'

interface ProductState {
  selectedProduct: Product | null,
  globalText: string

}

const initialState: ProductState = {
  selectedProduct: null,
  globalText: '请告诉全世界'
}

const productSlice = createSlice({
  name: 'product',
  initialState,
  reducers: {
    setSelectedProduct: (state, action) => {
      state.selectedProduct = action.payload
    },
    setGlobalText: (state, action) => {
      state.globalText = action.payload
    }
  }
})

export const { setSelectedProduct, setGlobalText } = productSlice.actions
export default productSlice.reducer
